/*
 * SnowFlake.h
 *
 *  Created on: 2022-02-23
 *      Author: chuanjiang.zh
 */

#ifndef SRC_SNOWFLAKE_H_
#define SRC_SNOWFLAKE_H_

#include "BasicType.h"
#include "DateTime.h"
#include "TRandom.h"

namespace comn
{


class SnowFlake
{
public:

    static int64_t make(int worker)
    {
        int64_t id = comn::DateTime::getTime();
        id = id << 12;
        id += ((worker & 0x3F) << 12);
        id += comn::Random::makeNumber(0x0FFF);

        return id;
    }

};


}

#endif /* SRC_SNOWFLAKE_H_ */
